<!-- view -->
 <template>
  <div>
    <h1>{{ msg }}</h1>
    <div>
      <p>获取状态对象并取值:count: {{ $store.state.count }}</p>
      <button @click="increment">点击+</button>
      <button @click="decrement">点击-</button>
    </div>
  </div>
</template> 

<script>
export default {
  name: "Test2",
  props: {
    msg: String,
  },
  methods: {
    increment() {
      this.$store.commit("increment");
      console.log("increment:" + this.$store.state.count);
    },
    decrement() {
      this.$store.commit("decrement");
      console.log("decrement:" + this.$store.state.count);
    },
  },
};
</script>
